<script>
  function success(msg, fun) {
    $.cxDialog({
      title: '消息提示',
      info: msg,
      closeBtn: false
    });
    setTimeout(function () {
      $.cxDialog.close();
      fun()
    }, 2000);
  }

  function error(msg, fun) {
    $.cxDialog({
      title: '消息提示',
      info: msg,
      closeBtn: false
    });
    setTimeout(function () {
      $.cxDialog.close();
      fun()
    }, 2000);
  }

  function confirm(info, fun, nfun) {
    $.cxDialog({
      title: '消息提示',
      info: info,
      okText: '确认购买',
      noText: '我再想想',
      ok: function () {
        fun()
      },
      no: function () {
        $.cxDialog.close();
      }
    });
  }
</script>

<!--投资管理-->
<div id="memberMain" class="success">
  <div class="title"><h4>增值消费</h4></div>
  <div class="tipsTop">一个账号一个月限消费一次</div>
  <div class="height18"></div>
  <h2>&nbsp;&nbsp;&nbsp;该模式尚未开启，敬请期待!</h2>
  <!--<form autocomplete="off" id="recharge-form">
    <input type="hidden" name="__token__" value="924aa57eaf9be77c75f4bc3f39061570">
    <ul class="formUl" id="userBank">
      <li class="">
        <label class="inputName">会员编号</label>
        <input class="inputText cardName" name="username" value="" id="username" type="text"
               style="color: rgb(0, 0, 0);" disabled="">
      </li>
      <li class="">
        <label class="inputName">积分类型</label>
        <select name="style" id="style">
          <option value="original">原始积分(0.00)</option>
          <option value="repeat">复投积分(0.00)</option>
        </select>
      </li>
      <li class="">
        <label class="inputName">投入积分</label>
        <select name="money" id="money">
          <option value="0">请选择额度</option>
          <option value="2000">投入2000积分</option>
          <option value="5000">投入5000积分</option>
          <option value="10000">投入10000积分</option>
          <option value="20000">投入20000积分</option>
        </select>
      </li>
      <li class="">
        <label class="inputName">交易密码</label>
        <input class="inputText" maxlength="6" name="pay_pwd" id="pay_pwd" type="text"
               style="color: rgb(0, 0, 0);">
      </li>
    </ul>
    <ul class="formUl">
      <li>
        <input class="inputBut showL inputBtnBig" type="button" value="确认" id="jax">
      </li>
    </ul>
  </form>-->
</div>

<script type="text/javascript">
  $(function () {

    $("*[name='pay_pwd']").focus(function () {
      $(this).attr('type', 'password');
    })

    $('#jax').bind('click', buy);

    function buy() {
      var money = $('#money').val();
      if (money == 0) {
        error('请选择一个消费额度', function () {

        })
        return false;
      }
      var info = '你正在消费的金额为:' + money + ',是否确认消费?';
      confirm(info, function () {
        //$('body').mLoading('show');
        var pointType = 1;
        if ($("#style").val() == "original")
          pointType = 4;
        else if ($("#style").val() == "capital")
          pointType = 7;
        else
          pointType = 5;
        var payPwd = $.md5($('#pay_pwd').val());
        $.post('/transaction/invest', {
          payPwd: payPwd,
          ruleId: 2,
          investPoint: money,
          pointType: pointType
        }, function (data) {
          if (data.retCode == 1) {
            //$('body').mLoading('hide');
            success(data.retMsg, function () {
              location.href = "/index.html#!/transaction/center/investing";
            })
          } else {
            //$('body').mLoading('hide');
            error(data.retMsg, function () {

            })
          }
        })
      })
    }

    function getPoint() {
      $.post('/transaction/getPoint', {}, function (data) {
        if (data.retCode == 1) {
          $('option[value=original]').html("原始积分(" + data.data.cpOriginalPoint + ")");
          $('option[value=repeat]').html("复投积分(" + data.data.cpRepeatPoint + ")");
        } else {

        }
      })
    }

    getPoint();

    function getUser() {
      $.post('/user/currentUser', {}, function (data) {
        if (data.retCode == 1) {
          $('#username').val(data.data.userName);
        } else {

        }
      })
    }

    getUser();
  })
</script>
